﻿using System;
using log4net;
using TY.UC.Common.Extension;

namespace TY.UC.Log4
{
    /// <summary>
    ///     LogHelper的摘要说明。
    /// </summary>
    public class Log4NetHelper
    {
        /// <summary>
        ///     静态只读实体对象info信息
        /// </summary>
        private static readonly ILog Loginfo = LogManager.GetLogger("loginfo");

        private static readonly ILog LogError = LogManager.GetLogger("logerror");

        /// <summary>
        ///     添加异常信息
        /// </summary>
        /// <param name="info">主信息</param>
        /// <param name="param">异常参数</param>
        /// <param name="ex"></param>
        public static void WriteLog(string info, Exception ex = null,object param =null)
        {
            if (param != null)
                info += param.JsonSe();
            if (ex == null)
                Loginfo.Info(info);
            else
                LogError.Error(info, ex);
        }
    }
}
